/*
https://leetcode.cn/problems/longest-common-prefix/submissions/578105441/
*/
class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        int len=2000;
        int k=0;
        for(int i=0;i<strs.size();++i){
            len=len>strs[i].size()?strs[i].size():len;
            k=i;
        }
        string ans="";
        for(int t=0;t<len;++t){
            char ch=strs[k][t];
            for(int i=0;i<strs.size();++i){
                if(strs[i][t]!=ch){
                    return ans;
                }
            }
            ans+=ch;
        }
        return ans;
    }
};